<template>
  <div>
    <table v-for="i in taskdata" :key="i.id">
      <tr>
        <td @click="sss(i.id)">{{i.id}}</td>
          </tr>
            <tr><td>姓名：{{i.title}}</td></tr>
              <tr><td>
                <van-radio-group v-model="checked">
              <van-radio name="1">同意</van-radio>
              <van-radio name="2">不同意 2</van-radio>
              </van-radio-group>
            </td></tr>
          <van-field label="审批理由" v-model="reasonapprove" />
        </table>
      <van-button @click="submittask">提交 </van-button>
  </div>
</template>

<script>
import myaxios from '../components/http/axios'
import { ref } from 'vue';
export default {
    name:'taskcenter',
     setup() {
        const checked = ref('1');
        return { checked };
    },
    data(){
        return{
            taskdata:[],
            id:this.$route.query.id,           // 这是title
            reasonapprove:"",
            tid:''

        }
    },
    methods:{
        gettask(){
            myaxios('getdevise?id=' + this.id,'get').then(res=>{
                this.taskdata = res.list
                
                console.log(res.list);
            })
        },
        sss(id){
            this.tid = id
            console.log(this.tid);
        },
        submittask(){
          let data = new FormData()
          data.append('userid',localStorage.getItem('userid'))      // 取出用户id
          data.append('name',localStorage.getItem('username'))      // 从前端库中取出用户名称，也就是审批人名称
          data.append('taskid',this.tid)                                 // 任务id
          data.append('agree',this.checked)                           // 是否同意
          data.append('reason',this.reasonapprove)                  //  意见
          
          myaxios('taskrecordM','post',data).then(res=>{
            console.log(res);

          })
        }
    },
    mounted(){
        this.gettask()
    }

}
</script>

<style>

</style>